// components/selectorBackgroundView/selectorBackgroundView.js
var _this
Component({
  options: {
    multipleSlots: true // 在组件定义时的选项中启用多slot支持
  },
  /**
   * 组件的属性列表
   */
  properties: {
    showPreBtn: {
      type: Boolean,
      value: true,
      observer: function (newVal, oldVal, changedPath) {
        _this = this
      }
    },
    showSureBtn: {
      type: Boolean,
      value: false,
      observer: function (newVal, oldVal, changedPath) {
        _this = this
      }
    },
    showCancelBtn: {
      type: Boolean,
      value: false,
      observer: function (newVal, oldVal, changedPath) {
        _this = this
      }
    },
    showSlot2: {
      type: Boolean,
      value: false,
      observer: function (newVal, oldVal, changedPath) {
        _this = this
      }
    },
    currentAndTotal: {
      type: String,
      value: '',
      observer: function (newVal, oldVal, changedPath) {
        _this = this
        if (newVal.trim() != oldVal.trim()) {
        }
      }
    },
    title: {
      type: String,
      value: '',
      observer: function (newVal, oldVal, changedPath) {
        _this = this
        if (newVal.trim() != oldVal.trim()) {
        }
      }
    },
    sureTitle: {
      type: String,
      value: '',
      observer: function (newVal, oldVal, changedPath) {
        _this = this
        if (newVal.trim() != oldVal.trim()) {
        }
      }
    },
    cancelTitle: {
      type: String,
      value: '',
      observer: function (newVal, oldVal, changedPath) {
        _this = this
        if (newVal.trim() != oldVal.trim()) {
        }
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    sureBtnStyle: 'btnNormal',
    cancelBtnStyle: 'btnNormal',
  },

  /**
   * 组件的方法列表
   */
  methods: {
    lifetimes: {
      attached() {
        console.log(_this)
      },
      detached() {
        // 在组件实例被从页面节点树移除时执行
      },
    },
    sureBtnClick: function(){
      _this.finishedHandle(1)
      this.setData({
        sureBtnStyle: 'btnSelected',
        cancelBtnStyle: 'btnNormal'
      })
    },
    cancelBtnClick: function () {
      _this.finishedHandle(2)
      this.setData({
        sureBtnStyle: 'btnNormal',
        cancelBtnStyle: 'btnSelected'
      })
    },
    finishedHandle: function (action) {
      const data = {'action': action }
      const option = {}
      _this.triggerEvent('finishedHandle', data, option)
    },
    preBtnClick: function() {
      _this.finishedHandle(0)
    }

  }
})
